#include "team.h"
#include "unit.h"

Team::Team(quint8 number, const QString& name)
    : QList<Unit*>(), m_number(number), m_name(name)
{

}

void Team::append(Unit* unit)
{
    unit->setTeamNumber(m_number);
    return QList<Unit*>::append(unit);
}

void Team::append(const QList<Unit*>& units)
{
    for(int i = 0 ; i < size() ; ++i)
    {
        Team::append(units.at(i));
    }
}

bool Team::removeOne(Unit* unit)
{
    bool removed = QList<Unit*>::removeOne(unit);
    if(removed)
    {
        unit->setTeamNumber(NO_TEAM);
    }

    return removed;
}

quint8 Team::getNumber() const
{
    return m_number;
}

const QString& Team::getName() const
{
    return m_name;
}
